<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>极氪官网汽车换色2</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    html,body{
      width: 100%;
      height: 100%;
    }
    .cart-box{
      width: 100%;
      height: 100vh;
      position: absolute;
      top: 0;
    }
    .box{
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      object-fit: cover;
      width: 100%;
      height: 100vh;
    }
    .box1 {
      background: pink;
    }
    .box2 {
      cursor: pointer;
      background-color: rgb(153, 181, 234);
    }

    .box img{
      width: 62rem;
      position: absolute;
      pointer-events: none;
      left: 50%;
      top: 50%;
      transform: translate(-50%,-50%);
    }
  </style>
</head>
<body>
  <div class="cart-box">
    <div class="box box1">
      <img src="./img/car_orange_2023.png" alt="">
    </div>
    <div class="box box2" >
      <img src="./img/car_jblue_2023.png" alt="">
    </div>
  </div>
</body>
<script>
  // 得到box1元素
  const cart = document.querySelector('.cart-box')
  // 得到box2元素
  const box2 = document.querySelector('.box2')
  // 注册鼠标移动事件
  cart.onmousemove = function(e){
    // 得到鼠标在box2中的坐标
    const x = e.offsetX
    // 设置box1的clip-path属性
    box2.style.clipPath = `circle(25vh at ${x}px 50%)`
  }

</script>
</html>
